home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 3.3 KB | 154 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWRepMem.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #if defined(FW_PROFILER_CALLS) && defined(__MWERKS__)
- #pragma profile on
- #endif
-
- #ifndef FWINK_H
- #include "FWInk.h"
- #endif
-
- #ifndef FWSTYLE_H
- #include "FWStyle.h"
- #endif
-
- #ifndef FWFONT_H
- #include "FWFont.h"
- #endif
-
- #ifndef FWPAT_H
- #include "FWPat.h"
- #endif
-
- #ifndef FWBWPAT_H
- #include "FWBWPat.h"
- #endif
-
- #ifndef FWCPAT_H
- #include "FWCPat.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWFIXMEM_H
- #include "FWFixMem.h"
- #endif
-
- //========================================================================================
- // Memory management
- //========================================================================================
-
- #define FW_SUBALLOCATE
-
- //----------------------------------------------------------------------------------------
- // FW_CInkRep
- //----------------------------------------------------------------------------------------
-
- static FW_CFixedAllocator gInkAllocator = sizeof(FW_CInkRep);
-
- void* FW_CInkRep::operator new(size_t size)
- {
- FW_ASSERT(size == sizeof(FW_CInkRep));
- #ifdef FW_SUBALLOCATE
- return gInkAllocator.Allocate();
- #else
- return ::operator new(size);
- #endif
- }
-
- void FW_CInkRep::operator delete(void* p)
- {
- #ifdef FW_SUBALLOCATE
- gInkAllocator.Free(p);
- #else
- ::operator delete(p);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CStyleRep
- //----------------------------------------------------------------------------------------
-
- static FW_CFixedAllocator gStyleAllocator = sizeof(FW_CStyleRep);
-
- void* FW_CStyleRep::operator new(size_t size)
- {
- FW_ASSERT(size == sizeof(FW_CStyleRep));
- #ifdef FW_SUBALLOCATE
- return gStyleAllocator.Allocate();
- #else
- return ::operator new(size);
- #endif
- }
-
- void FW_CStyleRep::operator delete(void* p)
- {
- #ifdef FW_SUBALLOCATE
- gStyleAllocator.Free(p);
- #else
- ::operator delete(p);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CFontRep
- //----------------------------------------------------------------------------------------
-
- static FW_CFixedAllocator gFontAllocator = sizeof(FW_CFontRep);
-
- void* FW_CFontRep::operator new(size_t size)
- {
- FW_ASSERT(size == sizeof(FW_CFontRep));
- #ifdef FW_SUBALLOCATE
- return gFontAllocator.Allocate();
- #else
- return ::operator new(size);
- #endif
- }
-
- void FW_CFontRep::operator delete(void* p)
- {
- #ifdef FW_SUBALLOCATE
- gFontAllocator.Free(p);
- #else
- ::operator delete(p);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CPatternRep
- //----------------------------------------------------------------------------------------
-
- #define MAX(a, b) ((a) > (b) ? (a) : (b))
-
- static FW_CFixedAllocator gPatternAllocator =
- MAX(sizeof(FW_CBWPatternRep), sizeof(FW_CColorPatternRep));
-
- void* FW_CPatternRep::operator new(size_t size)
- {
- #ifdef FW_SUBALLOCATE
- return gPatternAllocator.Allocate();
- #else
- return ::operator new(size);
- #endif
- }
-
- void FW_CPatternRep::operator delete(void* p)
- {
- #ifdef FW_SUBALLOCATE
- gPatternAllocator.Free(p);
- #else
- ::operator delete(p);
- #endif
- }
-
-